<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ attribute name="pager" type="java.lang.Object" required="true"
%><%@ attribute name="url" type="java.lang.String" required="true"
%><%@ attribute name="form" type="java.lang.Object" required="true"
%><%@ attribute name="smartSearch" type="java.lang.Boolean"
%><%

String appender = "";
if (url.contains("?") && !url.endsWith("?")) {
    appender = "&amp;";
} else {
    appender = "?";
}
%>

<b class="total">
<c:if test="${pager.totalSize != null}">
<fmt:message key="navigation.total">
    <fmt:param value="${pager.totalSize}" />
</fmt:message>
</c:if>
<c:if test="${pager.totalSize == null}">
<fmt:message key="navigation.total">
    <fmt:param value="0" />
</fmt:message>
</c:if>
</b>
<c:choose>
    <c:when test="${pager.pageIndex > 1 }">
        <a id="nextLinkFirst" class="pageFirst ajaxPagerLink" href="${url}<%= appender %>${form.queryStringForPager}&amp;searchParameters.pageNumber=1"><fmt:message key="navigation.first"/></a>
    </c:when>
    <c:otherwise>
        <b class="pageFirst"><fmt:message key="navigation.first"/></b>
    </c:otherwise>
</c:choose>

<c:choose>
    <c:when test="${pager.hasPreviousPage}">
        <a id="nextLinkPrevious" class="pagePrev ajaxPagerLink" href="${url}<%= appender %>${form.queryStringForPager}&amp;searchParameters.pageNumber=${pager.pageIndex - 1}"><fmt:message key="navigation.previous"/></a>
    </c:when>
    <c:otherwise>
        <b class="pagePrev"><fmt:message key="navigation.previous"/></b>
    </c:otherwise>
</c:choose>

<c:choose>
    <c:when test="${smartSearch == null}">
        <span class="pager">${pager.pageIndex} / ${pager.totalPages}</span>
    </c:when>
    <c:otherwise>
        <span class="pager">${pager.pageIndex}</span>
    </c:otherwise>
</c:choose>

<c:choose>
    <c:when test="${pager.hasNextPage}">
        <a id="nextLinkNext" class="pageNext ajaxPagerLink" href="${url}<%= appender %>${form.queryStringForPager}&amp;searchParameters.pageNumber=${pager.pageIndex + 1}"><fmt:message key="navigation.next"/></a>
    </c:when>
    <c:otherwise>
        <b class="pageNext"><fmt:message key="navigation.next"/></b>
    </c:otherwise>
</c:choose>


<c:if test="${smartSearch == null}">
    <c:choose>
        <c:when test="${pager.pageIndex < pager.totalPages }">
            <a id="nextLinkLast" class="pageLast ajaxPagerLink" href="${url}<%= appender %>${form.queryStringForPager}&amp;searchParameters.pageNumber=${pager.totalPages}"><fmt:message key="navigation.last"/></a>
        </c:when>
        <c:otherwise>
            <b class="pageLast"><fmt:message key="navigation.last"/></b>
        </c:otherwise>
    </c:choose>
</c:if>